package co.th.helper.jdbc.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import co.th.helper.jdbc.RowMapper;
import co.th.helper.model.Department;

public class DepartmentRowMapper extends RowMapper<Department>{

	@Override
	public Department mapRow(ResultSet resultSet) throws SQLException {
		Department department = new Department();
		
		if (isThere(resultSet, "department_code"))
			department.setDepartmentCode(resultSet.getBigDecimal("department_code"));
		
		if (isThere(resultSet, "department_name_th"))
			department.setDepartmentNameTH(resultSet.getString("department_name_th"));
		
		if (isThere(resultSet, "department_name_en"))
			department.setDepartmentNameEN(resultSet.getString("department_name_en"));
		
		if (isThere(resultSet, "department_detail"))
			department.setDepartmentDetail(resultSet.getString("department_detail"));
		
		if (isThere(resultSet, "create_by"))
			department.setCreateBy(resultSet.getString("create_by"));
		
		if (isThere(resultSet, "create_date"))
			department.setCreateDate(resultSet.getDate("create_date"));
		
		if (isThere(resultSet, "update_by"))
			department.setUpdateBy(resultSet.getString("update_by"));
		
		if (isThere(resultSet, "update_date"))
			department.setUpdateDate(resultSet.getDate("update_date"));
		
		return department;
	}
}
